<template>
	<view>
		登录页面
		<view>
			<input v-model="username" type="text" placeholder="请输入用户名">
			<input v-model="password" type="password" placeholder="请输入密码">
		</view>
		<button @tap="doLogin" type="primary" size="mini">登录</button>
	</view>
</template>

<script>
	import {doLogin as doLoginApi} from '@/api/login.js'
	export default {
		name:'Login',
		data() {
			return {
				username:'17596496508',
				password:'123456'
			};
		},
		methods:{
			async doLogin(){
				const res = await doLoginApi({
											"password": this.password, // MD5 加密
											"username": this.username
										})
				const {token} = res.data
				// 把token 保存在本地
				uni.setStorageSync("token",token)
				uni.showToast({
					title:"登录成功"
				})
				//成功后 返回上一页
				setTimeout(()=>{
					uni.navigateBack({
						delta:1
					})
				},1000)
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
